<template>
<span style="margin-left: 8px">
  <template v-if="!re">
    <el-link :disabled="true" icon="el-icon-delete" type="danger" :underline="false"
             v-if="(typeof status === 'boolean' && status) || status !== normalStatus">
      {{ delButton }}
    </el-link>
    <el-popconfirm class="ele-action" :title="delTitle" @confirm="$emit('confirm')" v-else>
      <el-link slot="reference" icon="el-icon-delete" type="danger" :underline="false">
        {{ delButton }}
      </el-link>
    </el-popconfirm>
  </template>

  <template v-else>
    <el-popconfirm class="ele-action" v-if="status === normalStatus" :title="delTitle"
                   @confirm="$emit('confirm', dellStatus)">
      <el-link slot="reference" icon="el-icon-delete" type="danger" :underline="false">
        {{ delButton }}
      </el-link>
    </el-popconfirm>
    <el-popconfirm class="ele-action" v-else :title="reTitle"
                   @confirm="$emit('confirm', normalStatus)">
      <el-link slot="reference" icon="el-icon-refresh-left" type="success" :underline="false">
        {{ reButton }}
      </el-link>
    </el-popconfirm>
  </template>
</span>
</template>

<script>
export default {
  name: 'popConfirmButton',
  props: {
    status: {
      type: Number,
      default: 0,
    },
    re: {
      type: Boolean,
      default: true
    },
    delTitle: {
      type: String,
      default: '确定要删除此记录吗？'
    },
    delButton: {
      type: String,
      default: '删除'
    },
    reTitle: {
      type: String,
      default: '确定要上架此记录吗？'
    },
    reButton: {
      type: String,
      default: '上架'
    },
    normalStatus: {
      type: Number,
      default: 1,
    },
    dellStatus: {
      type: Number,
      default: 2,
    }
  }
}
</script>

<style scoped>

</style>
